@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

.toggle-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 200px;
    height: 40px;
    padding: 10px;
    margin: 10px 0;
}

.toggle-container .toggle {
    opacity: 0;
}

.toggle-container .label {
    cursor: pointer;
    width: 80px;
    height: 40px;
    background-color: #d0d0d0;
    position: relative;
    border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    -ms-border-radius: 20px;
    -o-border-radius: 20px;
    transition: all .3s linear;
    -webkit-transition: all .3s linear;
    -moz-transition: all .3s linear;
    -ms-transition: all .3s linear;
    -o-transition: all .3s linear;
}

.label .ball {
    background-color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    -ms-border-radius: 50%;
    -o-border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    animation: slideOff 0.3s linear forwards;
}

.toggle-container span {
    margin-left: 20px;
}

.toggle-container .toggle:checked+.label {
    background-color: pink;
    transition: all .3s linear;
    -webkit-transition: all .3s linear;
    -moz-transition: all .3s linear;
    -ms-transition: all .3s linear;
    -o-transition: all .3s linear;
}

.toggle-container .toggle:checked+.label .ball {
    animation: slideOn 0.3s linear forwards;
}

@keyframes slideOn {
    0% {
        transform: translateX(0) scale(1);
    }

    50% {
        transform: translateX(20px) scale(1.2);
    }

    100% {
        transform: translateX(40px) scale(1);
    }
}

@keyframes slideOff {
    0% {
        transform: translateX(40px) scale(1);
    }

    50% {
        transform: translateX(20px) scale(1.2);
    }

    100% {
        transform: translateX(0) scale(1);
    }
}